﻿using SurveySez.Model;
using SurveySez.NavigationModel;
using SurveySez.ViewModel.Editor;
using UpdateControls.Correspondence;
using UpdateControls.Correspondence.SSCE;
using UpdateControls.XAML;
using SurveySez.ViewModel.GamePlay;

namespace SurveySez.ViewModel
{
	public class ViewModelLocator
	{
		private const string STR_ThisEmcee = "SurveySez.Emcee.thisEmcee";

		private PublicViewModel _public;
		private PrivateViewModel _private;

		public ViewModelLocator()
		{
			string correspondencePath = Directory.ApplicationData / "Michael L Perry" / "SurveySez" / "Correspondence.sdf";
			Community community = new Community(new SSCEStorageStrategy(correspondencePath))
				.RegisterAssembly(typeof(Emcee));

			Emcee emcee = community.LoadFact<Emcee>(STR_ThisEmcee);
			if (emcee == null)
			{
				emcee = community.AddFact(new Emcee());
				community.SetFact(STR_ThisEmcee, emcee);
			}

			IGamePresenter gamePresenter = new GamePresenter();
			_private = new PrivateViewModel(emcee, gamePresenter, new EditorNavigationModel());
			_public = new PublicViewModel(emcee, gamePresenter);
		}

		public object Private
		{
			get { return ForView.Wrap(_private); }
		}

		public object Public
		{
			get { return ForView.Wrap(_public); }
		}
	}
}
